package com.bingxue.edu.teacher.controller;

import com.bingxue.edu.framework.common.model.Response;
import com.bingxue.edu.management.auth.EmployeeAuthUtil;
import com.bingxue.edu.teacher.model.query.TeacherLessonStatQuery;
import com.bingxue.edu.teacher.model.query.TeacherScheduleLessonQuery;
import com.bingxue.edu.teacher.model.resp.TeacherScheduleLessonResp;
import com.bingxue.edu.teacher.model.resp.TeacherScheduleStatResp;
import com.bingxue.edu.teacher.service.TeacherScheduleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author panbo
 * @since 2024/11/7
 */
@Tag(name = "教师端小程序-排课模块")
@RestController
@RequestMapping("/t/schedule")
@RequiredArgsConstructor
public class TeacherScheduleController {

    private final TeacherScheduleService teacherScheduleService;

    @Operation(summary = "查询排课情况")
    @GetMapping("/lesson/list")
    public Response<List<TeacherScheduleLessonResp>> getScheduleLessonList(@Validated TeacherScheduleLessonQuery query) {
        String currentUserId = EmployeeAuthUtil.getCurrentUserId();
        if (EmployeeAuthUtil.isAssistTeacher()) {
            query.setAssistTeacherId(currentUserId);
        } else {
            query.setLeadTeacherId(currentUserId);
        }
        return Response.success(teacherScheduleService.getScheduleLessonList(query));
    }

    @Operation(summary = "查询排课数量")
    @GetMapping("/stat")
    public Response<TeacherScheduleStatResp> getScheduleLessonStat(@Validated TeacherLessonStatQuery query) {
        String currentUserId = EmployeeAuthUtil.getCurrentUserId();
        if (EmployeeAuthUtil.isAssistTeacher()) {
            query.setAssistTeacherId(currentUserId);
        } else {
            query.setLeadTeacherId(currentUserId);
        }
        return Response.success(teacherScheduleService.getScheduleLessonStat(query));
    }

}
